package tcu.iot.gasmanage.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import tcu.iot.gasmanage.entity.Value;
import tcu.iot.gasmanage.entity.home.SeriesData;
import tcu.iot.gasmanage.entity.Options;

import java.util.List;

@Repository
@Mapper
@Component("HomeMapper")
public interface HomeMapper {

    @Select("SELECT state,count(*) FROM equipment GROUP BY state")
    List<SeriesData> GetStateData();

    @Select("SELECT province,count(*) FROM equipment GROUP BY province")
    List<SeriesData> GetProvinceData();

    @Select("SELECT equipmentNumber,equipmentName FROM equipment WHERE site=#{site} AND signalStrength<>-1")
    List<String> getSiteEquipmentNumberWithSignal(String site);

    @Select("SELECT equipmentNumber,equipmentName FROM equipment WHERE site=#{site} AND signalStrength=-1")
    List<String> getSiteEquipmentNumberWithoutSignal(String site);

    @Select("SELECT equipmentName FROM equipment WHERE equipmentNumber=#{equipmentNumber}")
    String getEquipmentName(String equipmentNumber);

    @Select("SELECT equipmentNumber,equipmentName FROM equipment WHERE site=#{site}")
    @Results({@Result(property = "value", column = "equipmentNumber"), @Result(property = "label", column = "equipmentName")})
    List<Value> GetSiteEquipment(String site);
}
